package done.easy_001_100;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * 35. Search Insert Position 搜索插入位置
 * <p>
 * Example 1:
 * Input: [1,3,5,6], 5
 * Output: 2
 * Example 2:
 * Input: [1,3,5,6], 2
 * Output: 1
 * <p>
 * [1,3,5,6], 5 → 2
 * [1,3,5,6], 2 → 1
 * [1,3,5,6], 7 → 4
 * [1,3,5,6], 0 → 0
 *
 * @author 大硕
 * 2019-03-23 8:45 AM
 **/
@Slf4j
public class SearchInsertPosition {

    @SuppressWarnings("all")
    public int searchInsert(int[] nums, int target) {
        // 190323 first
        return -1;
    }

    @Test
    public void test() {
        int[] nums = new int[]{1, 3, 5, 6};
        int target = 2;
        log.info("result:{}", searchInsert(nums, target));
    }
}




























/*
public int searchInsert(int[] nums, int target) {
    if (nums[nums.length-1] < target) {
        return nums.length;
    }

    int left = 0;
    int right = nums.length - 1;

    while (left < right) {
        int mid = left + (right - left) / 2;
        if (nums[mid] == target) return mid;
        else if (nums[mid] < target) left = mid + 1;
        else right = mid;
    }

    return right;
}
*/
